package org.pray.activity.combination;

import java.util.ArrayList;
import java.util.List;

/**
 * Directory
 *
 * @author 春江花朝秋月夜
 * @since 2024/3/17 15:03
 */
//文件类，所有操作基本上都可实现
public class Directory extends Component{
    private List<Component> list=new ArrayList<>();
    @Override
    public void addComponent(Component component) {
        list.add(component);//新建目录
    }

    @Override
    public void removeComponent(Component component) {
        list.remove(component);//删除目录
    }

    @Override
    public Component getChild(int index) {
        return list.get(index);
    }

    @Override
    public void modifyName() {
        list.forEach(Component::modifyName);//所有都要改名
    }
}
